package com.googlecode.scenemaker3d.services
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	public class RenderScene extends EventDispatcher
	{
		private static var _instance:RenderScene;
		private static var isOK:Boolean = false;
		
		public var timer:Timer = new Timer(10);
		
		public function RenderScene()
		{	
			if(!isOK){
				throw(new Error("This is a singleton. Do not instantiate. Use RenderScene.instance"));
			}					
		}
		public static function get instance():RenderScene
        {
        	if(!_instance){
				isOK = true;
				_instance = new RenderScene();	
				isOK = false;
				
				_instance.timer.addEventListener(TimerEvent.TIMER, _instance.onInterval);
				_instance.timer.start();
			}
			return _instance;
        }
        //[Bindable("renderScene")]
		private function onInterval(e:TimerEvent):void{
			this.dispatchEvent(new Event("renderScene"));
		}
	}
}